<template>
  <div class='container'>
    <!-- <div class="m-20-t">
      <div class='app-row'>
        <span class="title bold width-100 align-right">收货人名称:</span>
        <el-input class='flex-1' v-model="accept_value"></el-input>
      </div>
      <div class='annotation m-10-t m-114-l'>
        <span>* 请修改收货人名称</span>
      </div>
    </div>
    <div class='app-row m-20-t'>
      <span class="title bold width-100 align-right">收货人地址:</span>
      <el-input class='flex-1' v-model="address_value"></el-input>
    </div>
    <div class='app-row m-20-t'>
      <span class="title bold width-100 align-right">收货人电话:</span>
      <el-input class='flex-1' v-model="mobile_value"></el-input>
    </div> -->
    <div class='app-row m-20-t'>
      <span class="title bold width-100 align-right">订单状态:</span>
      <el-select v-model="status_value" placeholder="请选择">
        <el-option
          v-for="item in status_options"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-select>
    </div>
    <div class="app-row j-c-c m-100-t">
      <el-button type="success" @click="edit_button">确认修改</el-button>
    </div>
  </div>
</template>

<script>
import order_request from '@/api/order_request'
export default {
  name: 'OrderEdit',
  // "待发货" "待收货" "已完成"
  data() {
    return {
      accept_value: '',
      mobile_value: '',
      email_value: '',
      address_value: '',
      status_options: [{
        value: '2',
        label: '已支付/待发货'
      }, {
        value: '101',
        label: '已发货'
      }, {
        value: '5',
        label: '已完成'
      }],
      status_value: ''
    }
  },
  created() {
    this.get_detail(this.$route.query.id)
  },
  mounted() {

  },
  methods: {
    edit_button() {
      const params = {
        accept_name: this.accept_value,
        id: this.$route.query.id,
        status: this.status_value
      }
      if (this.status_value == 101) {
        params.id = this.$route.query.id
        params.status = 0
        params.accept_name = this.accept_value
        params.distribution_status = 1
      }
      order_request.edit_order_go(params, res=> {
        this.$router.push('/order/order')
      })
    },
    get_detail(id) {
      order_request.detail_order({id}, res=> {
        console.log(res);
        let result = res.data
        this.accept_value = result.accept_name
        this.address_value = result.address
        this.mobile_value = result.mobile
        this.status_value = result.status==1?"未支付":result.status==2?"已支付/待发货":result.status==5?"已完成":''
      })
    },


  }
}
</script>

<style scoped>
@import "~@/styles/layout.scss";
</style>
